import { request } from "../utils/request";

// 获取植物列表
export function getAllPlants(query) {
  return request.get("/plant", query);
}

// 根据id获取植物信息
export function getPlantById(query) {
  return request.get("/plant/getPlantById", query);
}

// 根据名称查询
export function getPlantByName(query) {
  return request.get("/plant/getPlantsByName", query);
}

// 新增植物
export function addPlant(data) {
  return request.post("/plant", data);
}

// 编辑植物
export function editPlant(data) {
  return request.put("/plant", data);
}

// 删除植物
export function deletePlant(query) {
  return request.delete("/plant", query);
}

/* 下方为科普信息相关接口 */

// 获取全部科普植物
export function getKnowledgePlants() {
  return request.get("/plant/getKnowledgePlants");
}

// 根据科普id查询
export function getKnowledgePlantById(query) {
  return request.get("/plant/getKnowledgePlantById", query);
}

// 根据植物名称查询科普信息
export function getKnowledgePlantByName(query) {
  return request.get("/plant/getKnowledgePlantsByName", query);
}

// 新增科普植物
export function addKnowledgePlant(data) {
  return request.post("/plant/addKnowledgePlant", data);
}

// 删除科普植物
export function deleteKnowledgePlant(id) {
  return request.delete(`/plant/deleteKnowledgePlant?id=${id}`);
}

/* 以下为识别记录用 */

// 新增识别记录
export function addRecognizeRecord(data) {
  return request.post("/plant/addRecognizeRecord", data);
}

// 删除识别记录
export function deleteRecognizeRecord(id) {
  return request.delete(`/plant/deleteRecognizeRecord?id=${id}`);
}

// 获取全部识别记录
export function getAllRecognizeRecords() {
  return request.get("/plant/getAllRecognizeRecords");
}

// 根据用户id获取识别记录
export function getRecognizeRecordsByUserId(id) {
  return request.get(`/plant/getRecognizeRecordsByUserId?userId=${id}`);
}
